<?php require_once(dirname(__FILE__).'/inc/config.inc.php');IsModelPriv('admin_list'); ?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,initial-scale=1.0,user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<title>管理员列表 </title>
<link href="templates/css/style.css" rel="stylesheet" type="text/css" />
<link href="templates/css/pagination.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" charset="utf-8" src="templates/js/jquery-1.11.2.min.js"></script>
<script type="text/javascript" charset="utf-8" src="templates/js/layindex.js"></script>
<script type="text/javascript" charset="utf-8" src="templates/js/common.js"></script>
<script type="text/javascript" src="templates/js/forms.func.js"></script>
<script type="text/javascript">
function checkPagenum(id)
{	
var pn = document.getElementById(id).value; 
 location.href = "admin.php?checkPagenum="+pn;
}
</script>
</head>

<body class="mainbody">
<!--导航栏-->
<div class="location">
  <a href="javascript:history.back(-1);" class="back"><i></i><span>返回上一页</span></a>
  <a href="home.php" class="home"><i></i><span>首页</span></a>
  <i class="arrow"></i>
  <span>管理员列表</span>
  <a href="javascript:location.reload();" class="reload">刷新</a>
</div>
<!--/导航栏-->

<!--工具栏-->
<div id="floatHead" class="toolbar-wrap">
  <div class="toolbar">
    <div class="box-wrap">
      <a class="menu-btn"></a>
      <div class="l-list">
        <ul class="icon-list">
			 <?php if(IsModel('admin','add',1)!=false) echo'<li><a href="admin_add.php" class="add"><i></i><span>新增</span></a></li>';?>

        </ul>
      </div>
      <div class="r-list">
	  <form name="form3" id="form3" method="post" action="admin.php">
        <input name="keyword" type="text" id="keyword" class="keyword" />
        <input  class="btn-search" type="submit" value="搜索" style="cursor:pointer;">
		</form>
      </div>
    </div>
  </div>
</div>
<!--/工具栏-->
<form method="post" action="" id="form1">
<!--列表-->
<div class="table-container">
  
  <table width="100%" border="0" cellspacing="0" cellpadding="0" class="ltable">
    <tr>
      <th width="8%">ID</th>
      <th align="left">用户名</th>
      <th align="left" width="12%">姓名</th>
      <th align="left" width="12%">角色</th>
      <th align="left" width="12%">登录IP</th>
      <th align="left" width="16%">登录时间</th>
      <th width="8%">状态</th>
      <th width="8%">操作</th>
    </tr>
  
  	<?php

		$sql = "SELECT * FROM `#@__admin`WHERE id>0 ";

	if(!isset($checkPagenum)){$checkPagenum = $cfg_pagenum;}
	//如果非超级管理员,不显示超级管理员记录
	if($cfg_adminlevel != 1)
	$sql .= " AND`levelname`>=$cfg_adminlevel";
	if(!empty($keyword)) $sql .= " AND (username LIKE '%$keyword%' or nickname LIKE '%$keyword%' )";
	$dopage->GetPage($sql,$checkPagenum,'ASC');
	while($row = $dosql->GetArray())
	{
		$r = $dosql->GetOne("SELECT `groupname` FROM `#@__admingroup` WHERE `id`=".$row['levelname']);
		$groupname = isset($r['groupname']) ? $r['groupname'] : '';

		switch($row['checkadmin'])
		{
			case 'true':
				$checkadmin = '启用';
				break;  
			case 'false':
				$checkadmin = '禁用';
				break;
			default:
				$checkadmin = '没有获取到参数';
		}
	

		//审核权限
		if($row['id'] == 1)
			$checkstr = $checkadmin;
		elseif(IsModel('admin','Audit',1)==true)
				$checkstr = '<a href="admin_save.php?action=check&id='.$row['id'].'&checkadmin='.$row['checkadmin'].'&username='.$row['username'].'" title="点击是否启用">'.$checkadmin.'</a>';
			
			else
				$checkstr = $checkadmin;	

		//修改权限
			if(IsModel('admin','update',1)==true)
				$updatestr = '<a href="admin_update.php?id='.$row['id'].'"">修改</a>';
			else
				$updatestr = '修改';
		//删除权限
			if($row['id'] == 1)
			$delstr = '删除';
		elseif(IsModel('admin','del',1)==true)
			$delstr = '<a href="admin_save.php?action=del&id='.$row['id'].'&username='.$row['username'].'" onclick="return ConfDel(0);">删除</a>';
		else
			$delstr = '删除';
	?>
	 <tr>
      <td align="center">
        <?php echo $row['id']; ?>
      </td>
      <td><a href="admin_update.php?id=<?php echo $row['id']; ?>"><?php echo $row['username']; ?></a></td>
      <td><?php echo $row['nickname']; ?></td>
      <td><?php echo $groupname; ?></td>
      <td><?php echo $row['loginip']; ?></td>
      <td><?php echo GetDateTime($row['logintime']); ?></td>
      <td align="center"><span><?php echo $checkstr; ?></span></td>
    <td align="center"><span><?php echo $updatestr; ?></span> | <span class="nb"><?php echo $delstr; ?></span></td>
    </tr>

	<?php
	}
	?>

  </table>
  
</div>
<!--/列表-->

<!--内容底部-->
<div class="line20"></div>
<div class="pagelist">
  <div class="l-btns">
    <span>显示</span><input name="txtPageNum" type="text" value="<?php echo $checkPagenum;?>"  onblur="checkPagenum(this.id)"  onkeypress="if (WebForm_TextBoxKeyHandler(event) == false) return false;" id="txtPageNum" class="pagenum" onkeydown="return checkNumber(event);" /><span>条/页</span>
  </div>
  <?php echo $dopage->GetList($sql,$checkPagenum); ?>

</div>
<!--/内容底部-->
</form>
</body>
</html>
